package metier.sess;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import metier.entities.Publicite;


@Stateless(name="Publicite")
public class PubliciteEJBImpl implements IPubliciteLocal,IPubliciteRemote{
	@PersistenceContext(unitName="PU_Cargaison")
	private EntityManager em;
	
	@Override
	public void addPublicite(Publicite p) {
		em.merge(p);
	}

	@Override
	public List<Publicite> getAllPublicites(){
		Query req=em.createQuery("select p from Publicite p");
		return req.getResultList();
	}

	
	@Override
	public Publicite getPublicite(Integer Id) {
		Publicite p=em.find(Publicite.class, Id);
		return p;
	}

	@Override
	public void updatePublicite(Publicite p) {
		em.merge(p);
		
	}

	@Override
	public void deletePublicite(Integer Id) {
		Publicite p=getPublicite(Id);
		em.remove(p);
		
	}
	
	
}
